package day01.cn.itcast.reflect;

import day01.cn.itcast.doMain.Person;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * @author Lenovo
 */
public class ReflectDemo4 {
    public static void main(String[] args) throws NoSuchFieldException, IllegalAccessException, NoSuchMethodException, InvocationTargetException, InstantiationException {
        Class personClass=Person.class;
        Method eat_method=personClass.getMethod("eat");
        Person p=new Person();
        eat_method.invoke(p);

        Method eat_method2=personClass.getMethod("eat",String.class);
        eat_method2.invoke(p,"饭");
        System.out.println("--------");
        Method[] methods=personClass.getMethods();
        for (Method method:methods){
            System.out.println(method);
            //method.setAccessible(true);
        }
        String className=personClass.getName();
        System.out.println(className);

    }

}
